const http = require('http');
const url = require('url')
let serve = http.createServer((req, res) => {
    // let baseurl = req.url;
    // console.log('bbbbbbbbbbbb',baseurl);
    // let urlObj = url.parse(baseurl, true); // 处理url
    // urlObj.pathname; // 查询路径
    // console.log(urlObj);
    // let kw = urlObj.query.kw; // 获取query参数
    // console.log(kw);

    // 另一种方式new URL()
    let urlObj = new URL(req.url, 'http://127.0.0.1');
    console.log(urlObj.searchParams.get('kw'));// 获取query参数
    res.end('nodejs')
})

serve.listen(1086, () => {
    console.log('服务开启成功');
})